package inet.app.controller.parser;


import inet.app.controller.connect.JsonParser;
import inet.app.model.object.CauDe_Item;

import java.util.ArrayList;

import org.json.JSONObject;

import android.util.Log;

public class Parser_CauDe {


	private ArrayList<CauDe_Item> list = new ArrayList<CauDe_Item>();
	private CauDe_Item item;
	private String ITEMS = "items";
	private String CODE = "code";
	private String NAME = "name";
	private String DATE = "date";
	private String INFODATE = "infodate";
	private String BO= "bo";
	private String SODEP = "sodep";
	private String KETNHAT = "ketnhat";
	
	public Parser_CauDe () {
		
	}
	public ArrayList<CauDe_Item> getList(String url) {
		list = new ArrayList<CauDe_Item>();
		JSONObject jobject,object,job_items;
		JsonParser jParser = new JsonParser();
		jobject = jParser.getJSONFromUrl(url);
		String code,name,date,infodate,bo,sodep,ketnhat;
		try {
				String items = jobject.getString(ITEMS);
				job_items = new JSONObject(items);
				code= job_items.getString(CODE);
				name= job_items.getString(NAME);
				date= job_items.getString(DATE);
				infodate= job_items.getString(INFODATE);
				bo= job_items.getString(BO);
				sodep= job_items.getString(SODEP);
				ketnhat= job_items.getString(KETNHAT);
				
				item = new CauDe_Item(code, name, date, infodate, bo, sodep, ketnhat);
				list.add(item);
				
			return list;
        } catch (Exception e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
            return null;
        }
		
	}


}
